import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {resolve} from 'path'
import {prismjsPlugin} from 'vite-plugin-prismjs';
export default defineConfig({
    plugins: [
        vue(),
        prismjsPlugin({
            languages: 'all'
        })
    ],
    resolve: {
        alias: [
            {
                find: '@',                                   // 别名
                replacement: resolve(__dirname, 'src'),      // 别名对应地址
            },
            {
                find: 'components',
                replacement: resolve(__dirname, 'src/components'),
            }
        ]
    },
    server: {
        host: '0.0.0.0',
        port: 3000, // 设置服务启动端口号
        open: true, // 设置服务启动时是否自动打开浏览器
        // 代理
        proxy: {
            '/api': {
                target: 'http://127.0.0.1:8080',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '')
            },
        }
    }
})
